const state = {
  sites: [],
  currentSite: null,
  isJF: false,
  employeeId: null,
  employeeName: null,
  companyId: null,
  companyName: null,
  verified: false,
  wgkInfo: null,
  wgk_verified: false,
  idCard: null,
  idName: null,
  id: null,
  moduleCode: null
}
const mutations = {
  updateSiteInfo: (state, payload) => {
    state.sites = payload
    state.currentSite = payload.filter(item => item.currSite === true)[0]
    state.isJF = [3, 4].includes(state.currentSite.siteType)
  },
  updateCompanyInfo: (state) => {
    state.verified = uni.getStorageSync('verified')
    state.wgkInfo = uni.getStorageSync('wgkInfo')
    state.wgk_verified = uni.getStorageSync('wgk_verified')
    state.idCard = uni.getStorageSync('idCard')
    state.idName = uni.getStorageSync('idName')
    state.id = uni.getStorageSync('siteId')
    state.employeeId = uni.getStorageSync('employeeId')
    state.companyId = uni.getStorageSync('companyId')
    state.employeeName = uni.getStorageSync('employeeName')
    state.companyName = uni.getStorageSync('companyName')
  },
  clearSiteInfo: (state) => {
    state.sites = []
    state.currentSite = null
    state.employeeId = null
    state.employeeName = null
    state.companyId = null
    state.companyName = null
    state.verified = false
    state.wgkInfo = null
    state.wgk_verified = false
    state.idCard = null
    state.idName = null
    state.id = null
  }
}

export default {
  namespaced: true,
  state,
  mutations
}
